package com.zh.junit.dao;

import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import java.math.BigDecimal;

/**
 * @author ZH
 * @date 12:06 2023/2/28
 */
@Data
public class Book {
    private Long id;
    @NotEmpty
    @Length(max = 50, message = "长度不能超过50")
    private String title;
    @NotEmpty
    @Length(max = 50, message = "长度不能超过50")
    private String author;
    @NotEmpty
    @Length(max = 50, message = "长度不能超过50")
    private String press;

    @Min(value = 0, message = "价格不能<0元")
    @Max(value = 9999, message = "价格不能>9999元")
    private BigDecimal price;

    public Book(){}
    public Book(String title, String author, String press, BigDecimal price) {
        this.title = title;
        this.author = author;
        this.press = press;
        this.price = price;
    }
}
